-
Notifications
You must be signed in to change notification settings - Fork 334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added .NET client for Dapr Jobs API #1331
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
@philliphoff Any other changes you think should be made here? |
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
…net-sdk into scheduler-api
I'm seeing the E2E tests fail on my system following the recent merge with I did add two more unit tests to validate the DaprClientBuilder a bit more where it was lacking existing tests and those are passing. |
/// runtime gRPC client used by the consuming package. | ||
/// </summary> | ||
/// <exception cref="InvalidOperationException"></exception> | ||
protected (GrpcChannel channel, HttpClient httpClient, Uri httpEndpoint) BuildDaprClientDependencies() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this tuple will become unwieldy if/when the number of dependencies/options increase. I wonder if something like this would be more flexible:
public TClientBuilder Build()
{
DaprClientDependencies dependencies = // Generate dependencies;
return this.Build(dependencies);
}
protected virtual TClientBuilder Build(DaprClientDependencies dependencies);
protected sealed record DaprClientDependencies(GrpcChannel Channel, HttpClient HttpClient, Uri HttpEndpoint);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pulled this out primarily to remove duplicate code when spinning up clients in other packages ensuring that they're all using the same configuration data for endpoints, API keys and whatnot.
However, as was evidenced in the subscriptions implementation, this approach doesn't really lend itself to any use of injected functionality down the line (e.g. logging, compression handlers, serialization handlers, etc) provided by the developer at registration time. Do you have any thoughts on abandoning this approach altogether and instead opting for more of a DI-first, factory-style approach?
I'd be happy to put together a POC in a separate PR if you're more inclined to visit that elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the similarity of the downloads between Dapr.Client and Dapr.AspNetCore, I'm curious if you know if there have been any surveys done on just how many people use the DaprClient without relying on dependency injection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know of any, though my personal expectation is that more people are using the AspNetCore
provided DI method than building one manually.
src/Dapr.Jobs/Extensions/DaprJobsServiceCollectionExtensions.cs
Outdated
Show resolved
Hide resolved
src/Dapr.Jobs/Extensions/Helpers/Deserialization/ByteArrayDeserializationExtensions.cs
Outdated
Show resolved
Hide resolved
src/Dapr.Jobs/Extensions/Helpers/Serialization/DaprCronJobsSerializationExtensions.cs
Outdated
Show resolved
Hide resolved
src/Dapr.Jobs/Extensions/Helpers/Serialization/DaprCronJobsSerializationExtensions.cs
Outdated
Show resolved
Hide resolved
…ions.Configuration to InternalsVisibleTo on DaprClient. Whole solution builds without error now locally. Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
@philliphoff I've thought about where you were coming from in the review and have overhauled the API substantially. There's now a single That leaves the A
The Because a I removed the exceptions as they weren't actually used anymore and cleaned up the larger solution to remove the use of the two shared types in favor of accessing them from I'm working to add more unit tests for the I'm going to go back through the remaining review comments and address each, but I wanted to put the latest changes in one easy-to-find place. |
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
…vocation Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
… bugs along the way) Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
…age. Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
In the last several commits, I've been working to build out a regular expression that can evaluate whether a value in a I did want to call out why I opted for the approach I did in the latest commit. I created a separate project to run some benchmarking because I wanted to implement this in a performant way that also limited allocations and the results were mildly surprising. I have three different approaches called SeparateRegexThis approach reflects how I developed the whole expression - one segment at a time. It works by splitting the expression by a whitespace character. If there are fewer than 6 segments, it's not a Cron expression. Otherwise, evaluate each segment by its respective regular expression and return a boolean value reflecting if they all were a match or not. CombinedRegexThis approach builds off the completed work of the last one in that I create a compiled regular expression of the entire string (as follows) and evaluate the expression as provided:
GeneratorRegexThis utilizes the new approach introduced in .NET 7 of using a source generator to produce a pared down version of the regular expression engine to only those bits necessary for the provided expression. The results of a standard benchmarking run + memory diagnostics are as follows: Surprisingly, Separate performed the best, followed by the Generator approach and then Combined (all within 2 microseconds of one another, so pretty similar). But the allocations were a distinctly different story: Separate performed the worst by far with 5616 bytes versus 216 bytes for Combined and 152 for the Generator, which make a lot of sense and align with expectations. As the 1.15 release of Dapr will precede the release of .NET 9 and will continue to have full support for .NET 6, it means that while Regex source generators were introduced with .NET 7, use of the |
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
/// </summary> | ||
/// <param name="value">Argument value to check.</param> | ||
/// <param name="name">Name of Argument.</param> | ||
public static void ThrowIfNullOrEmpty([NotNull] string? value, string name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: ArgumentException.ThrowIfNullOrEmpty()
was added in .NET 7 (so we should be able to ditch this these methods as soon as .NET 6 is deprecated.
…fNullOrEmpty in Jobs SDK implementation Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
…mparisons. Updated all usages. Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
…ng with each call. Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1331 +/- ##
==========================================
+ Coverage 67.28% 68.01% +0.72%
==========================================
Files 174 187 +13
Lines 6025 6352 +327
Branches 671 722 +51
==========================================
+ Hits 4054 4320 +266
- Misses 1802 1853 +51
- Partials 169 179 +10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
…int failure when a cancellation was requested Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Description
Added a Dapr Jobs client for the new Jobs API.
This PR is intended to replace the previous one and was performed as a squash merge of it - the third commit (early on) was missing a period in my email address which apparently breaks the DCO process (even though I have an email alias and I can still receive email there). Because I cannot figure out how to fix multi-line comments, I'm providing this updated PR instead.
Issue reference
We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.
Please reference the issue this PR will close: #1321
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: